export class Storage {
  static set(key: string, value: any): void {
    try {
      uni.setStorageSync(key, JSON.stringify(value));
    } catch (error) {
      console.error('[Storage] 存储失败:', error);
    }
  }

  static get<T>(key: string, defaultValue?: T): T | undefined {
    try {
      const value = uni.getStorageSync(key);
      return value ? JSON.parse(value) : defaultValue;
    } catch (error) {
      console.error('[Storage] 读取失败:', error);
      return defaultValue;
    }
  }

  static remove(key: string): void {
    try {
      uni.removeStorageSync(key);
    } catch (error) {
      console.error('[Storage] 删除失败:', error);
    }
  }
}